#include "pch.h"
#include "record_video_factory.h"
#include "record_video_desktop_gdi.h"
#include "record_video_desktop_directx.h"
#include "record_video_camera_opencv.h"

#include "error_define.h"
#include "log_helper.h"

int record__video_new(RECORD_VIDEO_TYPES type, xue::record_video ** recorder)
{
	int err = AE_NO;
	switch (type)
	{
		//case DT_DESKTOP_FFMPEG_GDI:
		//	*recorder = (xue::record_desktop*)new xue::record_desktop_ffmpeg_gdi();
		//	break;
		//case DT_DESKTOP_FFMPEG_DSHOW:
		//	*recorder = (xue::record_desktop*)new xue::record_desktop_ffmpeg_dshow();
		//	break;
		//case DT_DESKTOP_WIN_DUPLICATION:
		//	*recorder = (xue::record_desktop*)new xue::record_desktop_duplication();
		//	break;
	case DT_DESKTOP_WIN_GDI:
		*recorder = (xue::record_video*)new xue::record_video_desktop_gdi();
		break;
	case DT_DESKTOP_WIN_DIRECTX:
		*recorder = (xue::record_video*)new xue::record_video_desktop_directx();
		break;
	case DT_CAMERA_OPENCV:
		*recorder = (xue::record_video*)new xue::record_video_camera_opencv();
		break;

	default:
		err = AE_UNSUPPORT;
		break;
	}

	return err;
}

void record__video_destroy(xue::record_video ** recorder)
{
	if (*recorder != nullptr) {
		(*recorder)->stop();

		delete *recorder;
	}

	*recorder = nullptr;
}